import java.io.File;

import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class ImageViewer extends Application {

	protected double i = 1;
	protected int im;

	@Override
	public void start(Stage stage) {
		// folder
		File mainDir = new File("/media/store/min/islamic images/");
		final File[] imgs = mainDir.listFiles();
		final int count = imgs.length;
		// load the image
		Image image = new Image(new File(
				"/media/store/min/islamic images/islam4m.com39.jpg").toURI()
				.toString());

		// simple displays ImageView the image as is
		final ImageView iv1 = new ImageView();
		iv1.setImage(image);

		Group root = new Group();
		Scene scene = new Scene(root);
		scene.setFill(Color.BLACK);

		scene.setOnKeyTyped(new EventHandler() {

			public void handle(Event arg0) {
				File string = imgs[im];

				iv1.setImage(new Image(string.toURI().toString()));

				im++;
				if (im == count) {
					im = 0;
				}
				// String bip = new File("/media/store/Downloads/mp3/q.mp3")
				// .toURI().toString();
				// Media hit = new Media(bip);
				// MediaPlayer mediaPlayer = new MediaPlayer(hit);
				//
				// mediaPlayer.setVolume(i);
				// mediaPlayer.play();
				// System.err.println(mediaPlayer.getVolume());
				// i = i / 2;

			}
		});
		HBox box = new HBox();
		box.getChildren().add(iv1);

		root.getChildren().add(box);

		stage.setTitle("ImageView");
		stage.setWidth(415);
		stage.setHeight(200);
		stage.setScene(scene);
		stage.sizeToScene();
		stage.show();
	}

	public static void main(String[] args) {
		Application.launch(args);
	}
}
